Page({
  data: {
    bgd197: "",
    bgd198: "",
    bgd199: "",
    bgd200: "",
    bgd201: "",
    bgd202: "",
    bgd203: "",
    bgd204: "",
    bgd205: "",
    bgd206: "",
    bgd207: "",
    bgd208: "",
    bgd209: "",
    bgd210: "",
    bgd211: "",
    bgd212: "",
    bgd213: "",
    bgd214: "",
    bgd215: "",
    bgd216: "",
    bgd217: "",
    bgd218: "",
    bgd219: "",
    bgd220: "",
    bgd221: "",
    bgd222: "",
    bgd223: "",
    bgd224: "",
  },
  onLoad: function () {
    console.log("order进来");
    //wx.clearStorage();
    var that = this;
    wx.request({
      url: 'http://localhost:8080/admin/selectAll',
      method: 'POST',
      data: {},
      success: function (res) {
        console.info("++++++++++=1", JSON.stringify(res));
        var list = res.data;
        console.info("++++++++++=2", JSON.stringify(list));
        if (list != null) {
          for (var index in list) {
            console.info("++++++++++=3", list[index]);
            var bathid = list[index];
            if (bathid == '198') {
              console.info("进来001");
              that.setData({
                bgd198: "red"
              });
            }
            if (bathid == "199") {
              console.info("进来002");
              that.setData({
                bgd199: "red"
              });
            }
            if (bathid == "200") {
              that.setData({
                bgd200: "red"
              });
            }
            if (bathid == "201") {
              that.setData({
                bgd201: "red"
              });
            }
            if (bathid == "202") {
              that.setData({
                bgd202: "red"
              });
            }
            if (bathid == "203") {
              that.setData({
                bgd203: "red"
              });
            }
            if (bathid == "204") {
              that.setData({
                bgd204: "red"
              });
            }
            if (bathid == "205") {
              that.setData({
                bgd205: "red"
              });
            }
            if (bathid == "206") {
              that.setData({
                bgd206: "red"
              });
            }
            if (bathid == "207") {
              that.setData({
                bgd207: "red"
              });
            }
            if (bathid == "208") {
              that.setData({
                bgd208: "red"
              });
            }
            if (bathid == "209") {
              that.setData({
                bgd209: "red"
              });
            }
            if (bathid == "210") {
              that.setData({
                bgd210: "red"
              });
            }
            if (bathid == "211") {
              that.setData({
                bgd211: "red"
              });
            }
            if (bathid == "212") {
              that.setData({
                bgd212: "red"
              });
            }
            if (bathid == "213") {
              that.setData({
                bgd213: "red"
              });
            }
            if (bathid == "214") {
              that.setData({
                bgd214: "red"
              });
            }
            if (bathid == "215") {
              that.setData({
                bgd215: "red"
              });
            }
            if (bathid == "216") {
              that.setData({
                bgd216: "red"
              });
            }
            if (bathid == "217") {
              that.setData({
                bgd217: "red"
              });
            }
            if (bathid == "218") {
              that.setData({
                bgd218: "red"
              });
            }
            if (bathid == "219") {
              that.setData({
                bgd219: "red"
              });
            }
            if (bathid == "220") {
              that.setData({
                bgd220: "red"
              });
            }
            if (bathid == "221") {
              that.setData({
                bgd221: "red"
              });
            }
            if (bathid == "222") {
              that.setData({
                bgd222: "red"
              });
            }
            if (bathid == "223") {
              that.setData({
                bgd223: "red"
              });
            }
            if (bathid == "224") {
              that.setData({
                bgd224: "red"
              });
            }
            if (bathid == "225") {
              that.setData({
                bgd225: "red"
              });
            }
            if (bathid == "226") {
              that.setData({
                bgd226: "red"
              });
            }
          }

          // wx.showToast({
          //   title: '获取数据失败',      
          //   duration: 1500      
          // })
        }
      }
    })
  },
  gotoresult: function (e) {
    var ID = e.currentTarget.id;
    console.log("idd", ID);
    // wx.clearStorage("userInfo");
    var stor = wx.getStorageSync("userInfo");
    var getkey = wx.getStorageSync("key1");
    if (stor == null || stor == "") {
      console.log("stor" + stor);
      wx.showModal({
        title: '提示',
        content: '您没有激活状态，请去激活',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');

            wx.hideToast()
            wx.switchTab({
              url: '../../login/login'
            })

            console.log('1');
            // return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })
    } else if (getkey) {
      wx.showModal({
        title: '提示',
        content: '您已经选择过！',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    } else {

      wx.request({
        url: 'http://localhost:8080/admin/byBathId',
        method: 'POST',
        data: { bathId: ID },
        success: function (res) {
          console.info("++++++++++=4", JSON.stringify(res));
          if (res.data == '1') {
            wx.showModal({
              title: '提示',
              content: '此澡位已被预订！',
              success: function (res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                  return;
                } else if (res.cancel) {
                  console.log('用户点击取消');
                  return;
                }
              }
            })
          }
        }

      })
      wx.showModal({
        title: '提示',
        content: '是否预定该位置',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            wx.setStorageSync("keykey", ID);
            wx.navigateTo({
              url: '../../seltime/seltime',
            })
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    }
    // wx.getStorage({
    //   key: 'key',
    //   success: function (res) {
    //     console.log(res.data);
    //     if(res){
    //       console.log(res);

    //       return;
    //     }
    //   },
    // });



  }



})